<!doctype html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>仓库管理系统-登录页</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" href="/resources/css/font.css">
    <link rel="stylesheet" href="/resources/css/xadmin.css">
    <link rel="stylesheet" href="/resources/css/login.css">
    <link rel="stylesheet" href="/resources/layui/css/layui.css">
</head>
<body class="login-bg">

<div class="login layui-anim layui-anim-up">
    <div class="message">仓库管理系统-登录</div>
    <div id="darkbannerwrap"></div>
    <form method="post" class="layui-form">
        <input name="loginname" placeholder="用户名" type="text" lay-verify="required" class="layui-input" value="system" >
        <hr class="hr15">
        <input name="userpwd" lay-verify="required" placeholder="密码" type="text" class="layui-input" value="123456">
        <hr class="hr15">
        <input name="code"  placeholder="请输入验证码" type="text" class="layui-input" >
        <img src="/login/code" onclick="this.src=this.src+'?'">
        <hr class="hr15">
        <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
        <hr class="hr20">
    </form>
</div>
<script type="text/javascript" src="/resources/js/jquery-3.3.1.min.js"></script>
<script src="/resources/layui/layui.js" charset="utf-8"></script>
<script>
    $(function () {
        layui.use('form', function () {
            var form = layui.form;
            // layer.msg('玩命卖萌中', function(){
            //   //关闭后的操作
            //   });
            //监听提交
            //登录按钮
            form.on("submit(login)", function (data) {
                var btn = $(this);
                //设置登录按钮  为不可点击
                btn.text("登录中...").attr("disabled", "disabled").addClass("layui-disabled");
                $.post("/login/login", data.field, function (rs) {
                    //设置登录按钮 恢复可点击   在前端防止 重复点击
                    btn.text("登录").attr("disabled", false).removeClass("layui-disabled");
                    layer.msg(rs.msg);
                    if (rs.code != 200) {
                        layer.msg(rs.msg);
                    } else {
                        //跳转到templates/system/index/index.html页面
                        layer.msg(rs.msg);
                        location.href = "/sys/index";
                    }
                });
                return false;
            });
        });
    })
</script>
</body>
</html>